import request from '@/config/axios'

export interface EvalObjectionVO {
  id?: number
  announcementId: number
  planId: number
  candidateId: number
  objectionType: string
  objectionReason: string
  evidenceMaterials?: string
  contactPhone?: string
  contactEmail?: string
  objectionStatus: number
  submitTime?: Date
  handleTime?: Date
  handlerId?: number
  handlerName?: string
  handleResult?: string
  handleComments?: string
  isAnonymous?: boolean
  urgencyLevel?: number
  followUpActions?: string
  createTime?: Date
}

export interface EvalObjectionPageReqVO extends PageParam {
  announcementId?: number
  planId?: number
  candidateId?: number
  objectionType?: string
  objectionStatus?: number
  urgencyLevel?: number
  submitTime?: Date[]
  handleTime?: Date[]
  createTime?: Date[]
}

export interface EvalObjectionSaveReqVO {
  id?: number
  announcementId: number
  planId: number
  candidateId: number
  objectionType: string
  objectionReason: string
  evidenceMaterials?: string
  contactPhone?: string
  contactEmail?: string
  isAnonymous?: boolean
  urgencyLevel?: number
}

export interface EvalObjectionHandleReqVO {
  id: number
  handleResult: string
  handleComments?: string
  followUpActions?: string
}

// 查询异议处理分页
export const getObjectionPage = (params: EvalObjectionPageReqVO) => {
  return request.get({ url: '/eval/objection/page', params })
}

// 查询异议处理详情
export const getObjection = (id: number) => {
  return request.get({ url: '/eval/objection/get?id=' + id })
}

// 新增异议处理
export const createObjection = (data: EvalObjectionSaveReqVO) => {
  return request.post({ url: '/eval/objection/create', data })
}

// 修改异议处理
export const updateObjection = (data: EvalObjectionSaveReqVO) => {
  return request.put({ url: '/eval/objection/update', data })
}

// 删除异议处理
export const deleteObjection = (id: number) => {
  return request.delete({ url: '/eval/objection/delete?id=' + id })
}

// 导出异议处理 Excel
export const exportObjection = (params: EvalObjectionPageReqVO) => {
  return request.download({ url: '/eval/objection/export-excel', params })
}

// 处理异议
export const handleObjection = (data: EvalObjectionHandleReqVO) => {
  return request.put({ url: '/eval/objection/handle', data })
}

// 获取异议统计
export const getObjectionStatistics = (planId?: number) => {
  const params = planId ? { planId } : {}
  return request.get({ url: '/eval/objection/statistics', params })
}
